package com.example.bankend.service.method;



import com.example.bankend.mapper.CustomerMapper;
import com.example.bankend.mapper.UserMapper;
import com.example.bankend.model.Customer;
import com.example.bankend.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserCustomerService {

    @Autowired
    private UserMapper userMapper;

    @Autowired
    private CustomerMapper customerMapper;

    public Customer getCustomerByUserName(String username) {
        // 通过用户名查询用户信息
        User user = userMapper.findUserByUserName(username);
        if (user == null) {
            return null; // 用户不存在
        }

        // 使用 pid 查询客户信息
        String pid = user.getPid();
        return customerMapper.selectByPrimaryKey1(pid);
    }
}
